/**
 * Created by yangfan on 2016/8/29.
 */
define(["business/home/config/routerconfig",'config/appregister',"../../services/httpServices","domReady","i18n","business/services/services",
    "business/services/detailNavComp",
    "jqueryMedia", "business/services/commentComp","business/home/directives/translate"],function(routercongfig, app, httpAjax, doc,i18n){
    app.controller('engdatabaseCtrl',function($scope,$state,$stateParams,$location,auth,$rootScope){
        $scope.i18n = i18n;
        var param = $stateParams;
        var local = $location.$$path.split('/');
        $scope.curentStateName = $state.current.name;
        $scope.isDetailPage = false;
        $scope.isMainpage = true;
        $scope.showUser = false;
        if(sessionStorage.loginConfig){
            $scope.showUser = true;
            $scope.userName = sessionStorage.loginConfig;
        }
        //logo跳转
        $scope.goIndexCtrl = function(){

            $state.transitionTo('indexCtrl',{},{reload: true, inherit: false, notify: true});
        }
        //导航页面跳转
        $scope.stateGoTo = function (state,num){
            if(state == "login"){
                var param = $state.current.name;
                sessionStorage.currentUrl = param ;
                if( typeof  num == "number"){
                    sessionStorage.loginType = null;
                    if(num == 0){
                        sessionStorage.loginType = 0;
                    }else if(num ==1){
                        sessionStorage.loginType = 1;
                    }
                }
                $state.go(state);
            }else{
                $state.go(state);
            }
            $scope.curentStateName = state;

        };
        $scope.showNavBox = false;
        $scope.navClass = "f-nav-out";
        //鼠标进入 改变导航区样式
        $scope.changeNav = function(curClass){
            if(curClass=$scope.navClass){
                $scope.navClass = "f-nav-enter";
            }
            $scope.showNavBox = true;
        };
        //鼠标移除 改变导航区样式
        $scope.mouseleave = function(mouseover){
            $scope.showNavBox = false;
            $scope.navClass = "f-nav-out"
        };
        //后台查询数据或缓存中查询数据。
        $scope.data = {
            "username":"Da Anna"
        };
        $scope.placeholder = "请输入您要输入的内容";
        $scope.mainData = {
            logoSrc:"them/images/gcj_big_logo.png"
        }

        // 点击资料 显示下拉框
        $scope.isShowData = false;
        $scope.isInList = false;
        
        $scope.clickData = function(){
            if($scope.isShowData == false){
                $scope.isShowData = true;
            }
        };
       
        $scope.gethystyle = function(ss){
        	if(ss==true){
        		return {
         	    	'position': 'absolute',
			    	'left': '52px',
			    	'top': '8px',
			    	'width': '16px',
			    	'height': '16px',
                	"background":"url('them/images/compImages/open-down.png') 0px 0px no-repeat",
			    	'background-size': '16px 16px'       			
        		}
        	}else{
        		return {
        	    	'position': 'absolute',
			    	'left': '52px',
			    	'top': '8px',
			    	'width': '16px',
			    	'height': '16px',
                	"background":"url('them/images/compImages/pull-up.png') 0px 0px no-repeat",
			    	'background-size': '16px 16px'        			
        		}
        	}
        }
        $scope.leaveSearchList =function(){
            if($scope.isShowData == true){
                $scope.isShowData = false;
            }
            $scope.isInList = true;
        };

        $scope.showBanner = false;
        $scope.onchange = {
            careEnter:function(){
                $scope.showBanner = true;
            },
            careLeave :function(){
                $scope.showBanner = false;
            }
        }
        $scope.jumpToUploadFile = function (state,params){
            auth.isLogin().then(function(){
                if(!angular.isUndefined(params)){
                    $state.go(state)
                }else {
                    $state.go(state,params)
                }
            })
        }

        $scope.jumpToUserUpload = function(item){
            if(item.userId == $rootScope.userLoginInfo.data.userId){
                $state.go('prosonMine.myUpload')
            }else{
                $state.go('personOther.upload',{userId:item.userId})
            }

        }
        $scope.jumpToUsersCenter = function(item){
            if(item.userId == $rootScope.userLoginInfo.data.userId){
                $state.go('myMainPage',{userId:item.userId})
            }else{
                $state.go('othersMainPage',{userId:item.userId})
            }
        }

    })
});